<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'addbook.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/javascript">
function isValid() {
	//alert(11);
	if (form1.bookID.value == "") {
		alert("The bookId is null !!");
		form1.bookID.focus();
	} else if (form1.bookName.value == "") {
		alert("The bookName is null !!");
		form1.bookName.focus();
	} else if (form1.author.value == "") {
		alert("The author is null!");
		form1.author.focus();
	} else if (form1.publish.value == "") {
		alert("The publish is null!");
		form1.publish.focus();
	} else if (form1.buyTime.value == "") {
		alert("The buyTime is null!");
		form1.buyTime.focus();
	} else if (form1.bookPrice.value == "") {
		alert("The price is null!");
		form1.bookPrice.focus();
	} else {

		document.forms.form1.submit();
	}

}

var DATE_FORMAT = /^[0-9]{4}-[0-1]?[0-9]{1}-[0-3]?[0-9]{1}$/;  
function checkDate() {
	var buyTime =document.getElementById("buyTime").value;
	if (!DATE_FORMAT.test(buyTime)) {
		alert("抱歉，您输入的日期格式有误，正确格式应为\"2012-01-01\".");
				form1.buyTime.focus();
	}
}
</script>

	</head>

	<body align="center" bgcolor="#0094D4">
		<form name="form1" action="/librarysystem/managerServlet"
			method="post">
			<table width="378" height="427" border="1" align="center">
				<tr align="center" bgcolor="#F3F3F3">
					<td colspan="3" bgcolor="#CCFFFF">
						添加图书
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td width="91" align="center" bgcolor="#EBEBEB">
						图书编号：
					</td>
					<td colspan="2">
						<input type="text" name="bookID" />
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						<p>
							图书名称：
						</p>
					</td>
					<td colspan="2">
						<input type="text" name="bookName" />
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						作者：
					</td>
					<td colspan="2">
						<input type="text" name="author" width="200px"">
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						出版社：
					</td>
					<td colspan="2">
						<input type="text" name="publish" />
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						入馆日期：
					</td>
					<td colspan="2">
						<input type="text" id="buyTime"name="buyTime" onblur="checkDate()" />
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						单价：
					</td>
					<td colspan="2">
						<input type="text" name="bookPrice" />
					</td>
				</tr>
				<tr bgcolor="#F3F3F3">
					<td align="center" bgcolor="#EBEBEB">
						状态：
					</td>
					<td colspan="2">
						可借：
						<input type="radio" name="bookStatus" value="1" checked="checked" />
						不可借：
						<input type="radio" name="bookStatus" value="0" />
					</td>
				</tr>
				<tr bgcolor="#EBEBEB">
					<td colspan="3" align="center">
						<table width="251" border="0">
							<tr>
								<td width="135">
									<input type="button" onclick="isValid()" value="提交" />
								</td>
								<td width="100">
									<input name="reset" type="reset" value="重置" />
								</td>
							</tr>
							<input type="hidden" name=actioncode value="addbook" />
						</table>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>
